home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
BUSINESS
/
TAS206.ARJ
/
SELECT.TAS
< prev
next >
Wrap
Text File
|
1991-02-17
|
9KB
|
239 lines
#OUTPUT_FILE 'select.lst'
#MAX_QUOTES 200
{
Technical Analysis Scanner (TAS)
--------------------------------
TAS is a product of Martin Moore
-----------------------------------------------------------------
TAS Script Language (TASSL) is similar to PASCAL syntax.
TAS has built-in TA functions and price arrays so that TASSL
scripts can be created by the user to screen a Metastock(*)
Data Directory (or directories) for stocks which match custom
criteria. The rest of this file gives an example of a TASSL
script. This entire file is the input for the TAS program.
(*) Metastock is a trademark of Equis International, Inc.
-----------------------------------------------------------------
A few notes about syntax:
------------------------- }
{comment} {- curly braces surround comments
a := b - ':=' is used to assign 'b' to 'a'
* / - + - multiply, divide, subtract, add
( expression) - parentheses are used to guarantee order of
evaluation is correct
IF (x) THEN - Conditions are tested with IF (cond) THEN true
tstmt; statement is executed. If (cond) is false, then
ELSE the ELSE (if present) portion is executed
fstmt;
Predefined Values : Filled in when each MSP file is processed
--------------------------------------------------------------
TICKER - The 'ticker' symbol, e.g., AXP
FULLNAME - The 'full name', e.g., AMERICAN EXPRESS
O - The OPEN "data array"
H - The HIGH "data array"
L - The LOW "data array"
C - The CLOSE "data array"
V - The VOLUME "data array"
OI - The OPEN INTEREST "data array"
P - The "last computed" array. For example,
X := MOV(C,30,'E')
places the last day's 30day EMA in 'X' and
the entire EMA array is in 'P' until another
function is called.
P1 - Secondary "last computed" array. For example,
if X := MACD() is executed, 'P' contains the
12day-26day EMA, and 'P1' contains the 9day EMA
of the MACD.
S A M P L E T A S S L S C R I P T
--------------------- SELECT.scr ---------------------------
This TASSL script contains the "Binary Wave" calculation
shown in the Metastock(*) 2.0 distribution system. It has been
modified to include the following indicators as well:
BUY SELL
Chaikin's Oscillator > 0 < 0
Commodity Channel Index > 100 < -100
Linear Regression Plot > close < close
It is here to give an example of the kind of analysis
available with the TASSL language.
The Metastock manual discusses this binary wave system on
page 187 of the User's Manual.
The script will put out a message if the value of the binary
wave changes from yesterday to today (the terms 'today' and
'yesterday' are used loosely, but meant to be the 'latest day'
and the 'day before', respectively).
Two variables are defined and updated as each of the four
individual binary wave formulas are checked.
They are:
"t_bwave" which is today's binary wave value (-6 to +6)
and
"y_bwave" which is yesterday's binary wave value (-6 to +6)
What we are looking for is a TRANSITION from yesterday to
today. If the stock moved to +6 today and it was lower yesterday,
perhaps this is a buying opportunity. If the stock moved to -6
perhaps it is a short sell.
}
linear_plot : array; { array for linear regression plot}
y_bwave := 0; { this is our 'score' yesterday}
t_bwave := 0; { this is our 'score' today}
{
First compute MACD Binary Wave for yesterday and today
Note that MACD() computes the 12 day EMA - 26 day EMA and places
the result in the array 'p'. The 9 day EMA is computed at the same
time and placed in the result array 'p1'
}
t_macd := macd(); { get today's macd value}
y_macd := p[-1]; { get yesterday's macd value}
t_macdtrigger := p1[0]; { result array 'p1' contains macd 'trigger'}
y_macdtrigger := p1[-1]; { yesterday's macd trigger }
if t_macd > t_macdtrigger then
t_bwave := t_bwave + 1; { macd greater than trigger }
else
t_bwave := t_bwave - 1; { macd less than trigger }
if y_macd > y_macdtrigger then
y_bwave := y_bwave + 1; { macd greater than trigger }
else
y_bwave := y_bwave - 1; { macd less than trigger }
{
Now compute 20-MA B-Wave
}
t_ma20 := mov(c,20,'E'); { Compute 20 unit EMA of close }
y_ma20 := p[-1]; { yesterday's EMA is in array 'p'}
if c[0] > t_ma20 then { compare today's close to today's ema}
t_bwave := t_bwave + 1; { ema greater than close }
else
t_bwave := t_bwave - 1; { ema less than close }
if c[-1] > y_ma20 then { compare yesterday's close to today's ema}
y_bwave := y_bwave + 1; { ema greater than close }
else
y_bwave := y_bwave - 1; { ema less than close }
{
Now compute 12-ROC B-Wave
}
t_roc12 := roc(c,12,'%');
y_roc12 := p[-1];
if t_roc12 > 0 then
t_bwave := t_bwave + 1; { roc greater than 0 }
else
t_bwave := t_bwave - 1; { roc less than 0 }
if y_roc12 > 0 then
y_bwave := y_bwave + 1; { roc greater than 0 }
else
y_bwave := y_bwave - 1; { roc less than 0 }
{
Now compute 5-3 stochastic B-wave
}
t_sto := stoch(5,3); { compute stoch(%K period, %K slow) }
y_sto := p[-1]; { result in 'p' array again }
if t_sto > 50 then
t_bwave := t_bwave + 1; { stoch greater than 50 }
else
t_bwave := t_bwave - 1; { stoch less than 50 }
if y_sto > 50 then
y_bwave := y_bwave + 1; { stoch greater than 50 }
else
y_bwave := y_bwave - 1; { stoch less than 50 }
{
check if Chaikin's AD oscillator is above or below 0
}
t_co := co();
y_co := p[-1];
t_bwave := t_bwave + (2 * (t_co > 0) - 1);
y_bwave := y_bwave + (2 * (y_co > 0) - 1);
{
check if CCI(14) above +100 or below -100
}
t_cci := cci(14);
y_cci := p[-1];
if t_cci < -100 then
t_bwave := t_bwave - 1;
else
if t_cci > 100 then
t_bwave := t_bwave + 1;
if y_cci < -100 then
y_bwave := y_bwave - 1;
else
if y_cci > 100 then
y_bwave := y_bwave + 1;
linear_plot := linreg(c,-51,-1); { compute linear regression line for
the last 50 days up to yesterday}
if over(linear_plot,c) >= 0 then
y_bwave := y_bwave + 1;
else
y_bwave := y_bwave - 1;
linear_plot := linreg(c,-50,0); { compute linear regression line for
the last 50 days up to today}
if over(linear_plot,c) >= 0 then
t_bwave := t_bwave + 1;
else
t_bwave := t_bwave - 1;
{
Okay, here we are at the end of the script. We have boiled
the seven formulas down to two values:
"t_bwave" which is today's binary wave value (-7 to +7)
and
"y_bwave" which is yesterday's binary wave value (-7 to +7)
}
{
First, let's check if the wave moved to +7..if so, let's print
out it's value then and now
}
y_bwave := INT(y_bwave); { make y_bwave into an INTEGER }
t_bwave := INT(t_bwave); { make t_bwave into an INTEGER }
if FIRST_TICKER then
begin
writeln(' \t \t\t\t \tPRIOR\tCURRENT ');
writeln(' \t \t\t\t\tBINARY\t BINARY ');
writeln('TICKER\t\tFULLNAME\t\t\t WAVE\t WAVE CHANGE ALERT');
end;
write(TICKER,'\t',fullname,'\t');
diff := INT(t_bwave-y_bwave);
write(y_bwave,' ',t_bwave,' ',diff);
if ((y_bwave < 7) and (t_bwave = 7)) then
writeln(' **BUY**')
{
Now, let's check if the wave moved to -7..if so, let's print
out it's value then and now
}
else
if ((y_bwave > -7) and (t_bwave = -7)) then
writeln(' **SELL**')
else
begin
writeln(' ');
end;
{-----------------END OF SELECT.TAS TASSL SCRIPT------------------}